// https://zm.quya.vip/api/v1/signIn
import tokenStore from "../utils/tokenStore";
export const signIn = async () => {
	return await new Promise(function(resolve, reject) {
		uni.request({
			method: 'POST',
			url: 'https://zm.quya.vip/api/v1/signIn',
			header: {
				'Authorization': 'Bearer ' + tokenStore.get()
			},
			success: (res) => {
				console.log(res)
				if (res.data.code == 200) {

					resolve(res.data.data)
				} else {
					uni.showToast({
						title: res.data.message || res.data.msg,
						icon: 'none'
					})
					reject(res.data)
				}
			}
		});
	});
}
export const getUserConsumptionLog = async (query) => {
	return await new Promise(function(resolve, reject) {

		let url = 'https://zm.quya.vip/api/v1/getUserConsumptionLog';
		query.page && (url += ('?page=' + query.page));
		query.pageSize && (url += ('&pageSize=' + query.pageSize));
		uni.request({
			// method: 'POST',
			url,
			header: {
				'Authorization': 'Bearer ' + tokenStore.get()
			},
			success: (res) => {
				console.log(res)
				if (res.data.code == 200) {

					resolve(res.data.data)
				} else {
					uni.showToast({
						title: res.data.message || res.data.msg,
						icon: 'none'
					})
					reject(res.data)
				}
			}
		});
	});
}